<script setup>
import { ref } from 'vue'
/**
  ref函数包裹的响应式数据
  - 在模板中使用, 正常使用
  - 在script标签中, 需要.value
 */
const person = ref({
  name: '张三',
  age: 18
})
const changeName = () => person.value.name = "李四"
const addAge = () => person.value.age++

const car = ref('自行车')
const changeCar = () => car.value = '问界M9'

</script>

<template>
  <div>
    <div>{{ person }}</div>
    <button @click="changeName">修改姓名</button>
    <button @click="addAge">增加年龄</button>
    <hr>
    <div>{{ car }}</div>
    <button @click="changeCar">换车</button>
  </div>
</template>

<style scoped></style>
